<!DOCTYPE html>

<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <title>Login</title>
 <script src="~/Scripts/jquery-1.10.2.min.js"></script>
 <script src="http://passport.cnblogs.com/scripts/jsencrypt.min.js"></script>
 <script type="text/javascript">
  $(function () {
   var encrypt = new JSEncrypt();
   encrypt.setPublicKey($("#tra").val());
   var data = encrypt.encrypt("123456789");
   alert(data);
   $("#btn").click(function () {
    $.ajax({
     url: '@Url.Action("Login")',
     data: "pwd=" + encodeURI(data).replace(/\+/g, '%2B'), //+号的处理：因为数据在网络上传输时，非字母数字字符都将被替换成百分号（%）后跟两位十六进制数，而base64编码在传输到后端的时候，+会变成空格，因此先替换掉。后端再替换回来
     type: 'post',
     success: function (msg) {
      alert(msg);
     }
    });
   });

  });


 </script>
</head>
<body>
 <div>
  <input type="button" id="btn" value="点我" />
  <textarea id="tra" rows="15" cols="65">
   MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa4KHNwDX44gGmmIAtRu4gjVYt
GWZzcm4t+1wjUD4dn7fMLPvuK7ai4UrfDeEJE1RPwudJw+lJ6crql8wSIg7/DbTl
   G3ihsCT6dT9H5B9OoeR7K9VWUesaW/iyVL6HXiYOANabW14pvJATDmdq91Tfgp6P
   SQyvdfiRdV4r07crpQIDAQAB
  </textarea>
  <hr/>
  注意+好的处理
 </div>
</body>
</html>